//
// Created by gogoqiu on 2021/10/14.
//

#ifndef RAPIDSVN_CMAKE_PREFERCENCELISTVIEW_H
#define RAPIDSVN_CMAKE_PREFERCENCELISTVIEW_H
#include "ListViewAdapter.h"
#include "../data/PreferenceStorage.h"
#include "../data/PreferenceView.h"
//preference
/*
class PreferenceData:public PreferenceView  {

};
 */
/*
enum PreferenceViewType{
    ViewType_INPUT,
    ViewType_SWITCH
};
 */

class ListItemPanel;
/**
 *
 */
template< class PreferenceData>
class PreferenceViewHolder:wxPanel{
private:
    //class MyObj;
    MyTagApp *myTagApp;
protected:
    PreferenceViewType viewType;
    //wxPanel *panel;
    //no default constructor
    PreferenceData* data;
public:
    PreferenceViewHolder( MyTagApp * myTagApp, wxWindow* parent, PreferenceData* _data );
    //find view
    //void findViews();
    //update
    //void update( PreferenceData* data );
    void OnClickItem(wxMouseEvent& event);
};



class MyTagApp;

/*
 * cpp如何表达class extend VH
 * mPreferenceAdapter = new PreferenceListAdapter();
 */
class PreferenceListAdapter: public ListViewAdapter<PreferenceView, PreferenceViewHolder<PreferenceView>>{
public:
    //
    PreferenceListAdapter( MyTagApp *myTagApp,
                          wxWindow *frame, wxScrolledWindow *listBox);

    void onBindViewHolder ( PreferenceViewHolder<PreferenceView>* holder, int position ) override;
    //
    void onBindViewHolder( PreferenceViewHolder<PreferenceView> *holder,
                           PreferenceView* date )  override;
    //wxFrame
    //ui thread side
    PreferenceViewHolder<PreferenceView>* onCreateViewHolder ( int viewType, PreferenceView* data ) override;

    //void setItemsWithNotify (  vector<PreferenceView*> infos ) override;

    //void appendItemsWithNotify (  vector<PreferenceView*> infos ) override;

    int getItemViewType ( int position ) override
    {
        //return super.getItemViewType(position);
        return 0;
    }

    /*
    int getItemCount() override{
        return items.size();
    }*/
protected:
    MyTagApp *myTagApp;
};
#endif //RAPIDSVN_CMAKE_PREFERCENCELISTVIEW_H
